package com.yunfeisoft.business.model;

import com.yunfeisoft.base.model.WorkflowInstance;
import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * ClassName: PrincipleApproval
 * Description: 员工违纪审批表
 *
 * @Author: Jackie liu
 * Date: 2020-05-14
 */
@Entity
@Table(name = "TT_PRINCIPLE_APPROVAL")
public class PrincipleApproval extends BaseModel implements Serializable {

    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 流程定义id
     */
    @Column
    private String workflowDefineId;

    /**
     * 部门
     */
    @Column
    private String deptName;

    /**
     * 姓名
     */
    @Column
    private String name;

    /**
     * 违纪事实
     */
    @Column
    private String content;

    /**
     * 处罚(1警告、2记过、3罚款、4辞退、5其他)
     */
    @Column
    private Integer punish;

    /**
     * 其他处罚
     */
    @Column
    private String otherPunish;

    /**
     * 备注
     */
    @Column
    private String remark;

    @TransientField
    private Integer validStatus;
    @TransientField
    private String createName;
    //下一节点处理人
    private String nextStepUserId;

    public String getPunishStr() {
        return PrinciplePunishEnum.valueOf(punish);
    }

    public String getValidStatusStr() {
        return WorkflowInstance.WorkflowInstanceStatusEnum.valueOf(validStatus);
    }

    public String getWorkflowDefineId() {
        return workflowDefineId;
    }

    public void setWorkflowDefineId(String workflowDefineId) {
        this.workflowDefineId = workflowDefineId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getPunish() {
        return punish;
    }

    public void setPunish(Integer punish) {
        this.punish = punish;
    }

    public String getOtherPunish() {
        return otherPunish;
    }

    public void setOtherPunish(String otherPunish) {
        this.otherPunish = otherPunish;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getValidStatus() {
        return validStatus;
    }

    public void setValidStatus(Integer validStatus) {
        this.validStatus = validStatus;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public String getNextStepUserId() {
        return nextStepUserId;
    }

    public void setNextStepUserId(String nextStepUserId) {
        this.nextStepUserId = nextStepUserId;
    }

    /**
     * 处罚(1警告、2记过、3罚款、4辞退、5其他)
     */
    public enum PrinciplePunishEnum {

        WARN(1, "警告"),
        RECORD_DEMERIT(2, "记过"),
        FINE(3, "罚款"),
        DISMISSAL(4, "辞退"),
        OTHER(5, "其他");

        private int value;
        private String label;

        private PrinciplePunishEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            for (PrinciplePunishEnum loop : PrinciplePunishEnum.values()) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }
    }
}